package org.lq.ssm.dto.mapper;

import org.lq.ssm.dto.UserDTO;
import org.lq.ssm.dto.util.UserDTOUtil;
import org.lq.ssm.po.DeptPO;
import org.lq.ssm.po.JobPO;
import org.lq.ssm.po.UserPO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper(uses = {UserDTOUtil.class})
public interface UserDTOMapper {

    UserDTOMapper INSTANCE = Mappers.getMapper( UserDTOMapper.class );

    @Mappings({
            @Mapping(source = "userPO.id" ,target = "id"),
            @Mapping(source = "jobPO", target = "job"),
            @Mapping(source = "deptPO", target = "dept"),
            @Mapping(source = "userPO.enabled" , target = "enabled" , qualifiedByName = {"userDTOUtil", "longTOBoolean"}),
            @Mapping(source = "userPO.createTime",target = "createTime")
    })
    UserDTO userToDTO(UserPO userPO, DeptPO deptPO, JobPO jobPO);

    //List<UserDTO> userListToDTOList(List<UserPO> usersPO);

}
